<?php

if($summary['items']){
	$rows = array();
	foreach($summary['items'] as $ware){
		foreach($ware['list'] as $dept){
			$row = array($ware['sno'], $ware['name'], $ware['brand'], $ware['specific'], $ware['unit']);
			
			$row[] = $dept[0]['amount'];
			if($dept[0].amount && floatval($ware.price)){
				$row[] = fnum($ware['price']);
				$row[] = fnum($ware['price'] * $dept[0]['amount']);
			}
			else{
				$row[] = '';
				$row[] = '';
			}
			
			$row[] = $dept[1]['amount'];
			if($dept[1].amount && floatval($ware.price)){
				$row[] = fnum($ware['price']);
				$row[] = fnum($ware['price'] * $dept[1]['amount']);
			}
			else{
				$row[] = '';
				$row[] = '';
			}
			
			$row[] = $dept[2]['amount'];
			if($dept[2].amount && floatval($ware.price)){
				$row[] = fnum($ware['price']);
				$row[] = fnum($ware['price'] * $dept[2]['amount']);
			}
			else{
				$row[] = '';
				$row[] = '';
			}
			
			$row[] = $ware['amount'];
			$row[] = fnum($ware['price']);
			$row[] = fnum($ware['total']);
			
			$row[] = $dept['name'];
			$row[] = $dept['supplier_name'];
			$row[] = $dept['remark'];
			
			$rows[] = $row;
		}
	}
	
	$head = array('材料编号','材料名称','品牌','规格','单位','补库数量','单价','金额','额外数量','单价','金额','紧急数量','单价','金额',
					'小计数量','单价','金额','部门','供应商','备注');
	array_unshift($rows, $head);
	Exporter::csv($rows, Lib::inputYearMonth('month').' 采购明细汇总');
}

?>
